export const FormatBalance = balance => {
  const r = parseFloat(balance).toLocaleString('en-US', {
    minimumFractionDigits: 8,
    maximumFractionDigits: 8,
  });
  return r;
};

export const ThousandsSeparator = num => {
  if(!num){
    return 0;
  }
  return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
};

export const SplitAndFormatBalance = num => {
  if(!num){
    return 0;
  }
  const formattedNum = (num / 100).toFixed(2);
  const parts = formattedNum.split('.');
  const integerPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  const decimalPart = parts.length > 1 ? '.' + parts[1] : '';
  return integerPart + decimalPart;
};
